package com.jakeprim.proxy.impl;

import com.jakeprim.proxy.BookFactory;
import com.jakeprim.proxy.GameFactory;

/**
 * 代理人
 * 静态代理
 */
public class JakeProxy implements GameFactory, BookFactory {

    GameFactory factory;

    /**
     * 告诉代理人 你要买的东西
     *
     * @param factory
     */
    public JakeProxy(GameFactory factory) {
        this.factory = factory;
    }

    @Override
    public String make() {
        //售前服务
        dosomethingBefore();
        String make = factory.make();
        System.out.println("make:" + make);
        //售后服务
        dosomethingAfter();
        return null;
    }

    private void dosomethingAfter() {
        System.out.println("售后服务");
    }

    private void dosomethingBefore() {
        System.out.println("售前服务");
    }

    @Override
    public String printed() {
        //越来越多的业务 会使这个代理类越来越难以维护
        return null;
    }
}
